from Function import *

n = 5
C = np.array([[1,2,3,4,5],[2,3,4,5,1],[3,4,5,1,2],[4,5,1,2,3],[5,1,2,3,4]])
A = np.zeros((n,n))
b = np.zeros((n,1))
for i in range(n):
    b[i,0] = 1
    for j in range(n):
        A[i,j] = 1/(i+j+1)
X = np.zeros((n,1))

A_hat = np.matmul(np.transpose(inv(C)),np.matmul(A,inv(C)))
b_hat = np.matmul(np.transpose(inv(C)),b)

ans = CG_Method(np.matmul(C,X),A_hat,b_hat,False,True)
ans2 = PRE_CG_Method(X, A, b, C, True)

for i in range(len(ans)):
    print(norm(np.matmul(C,ans2[i])-ans[i]))